package com.copa.l338;

import java.util.Arrays;

/**
 * @author copa
 * @createDate 2022-08-06 13:58
 * @function 遍历法
 */
public class Test1 {

    public int[] countBits(int n) {
        int[] result = new int[n + 1];
        for (int i = 0; i <= n; i++) {
            result[i] = Integer.bitCount(i);
        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Test1().countBits(5)));
    }
}
